<template>
  <el-container class="app-container">
    <el-aside width="200px" class="app-aside">
      <div class="logo-container">
        <h1 class="app-title">任务管理系统</h1>
      </div>
      <el-menu
        :router="true"
        class="nav-menu"
        background-color="#304156"
        text-color="#bfcbd9"
        active-text-color="#409EFF"
        :default-active="$route.path"
      >
        <el-menu-item index="/">
          <el-icon><el-icon-menu /></el-icon>
          <span>任务列表</span>
        </el-menu-item>
        <el-menu-item index="/task/new">
          <el-icon><el-icon-plus /></el-icon>
          <span>新建任务</span>
        </el-menu-item>
        <el-menu-item index="/analytics">
          <el-icon><el-icon-data-analysis /></el-icon>
          <span>数据分析</span>
        </el-menu-item>
      </el-menu>
    </el-aside>
    
    <el-container>
      <el-header class="app-header">
        <div class="header-content">
          <h2>{{ getPageTitle() }}</h2>
        </div>
      </el-header>
      
      <el-main class="app-main">
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { Menu as ElIconMenu, Plus as ElIconPlus, DataAnalysis as ElIconDataAnalysis } from '@element-plus/icons-vue'

const route = useRoute()

const getPageTitle = () => {
  const routeMap = {
    '/': '任务列表',
    '/task/new': '新建任务',
    '/analytics': '数据分析'
  }
  return routeMap[route.path] || '任务管理系统'
}
</script>

<style>
.app-container {
  min-height: 100vh;
}

.app-aside {
  background-color: #304156;
  color: #fff;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1000;
}

.logo-container {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #2b3649;
}

.app-title {
  margin: 0;
  font-size: 18px;
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-menu {
  border-right: none;
}

.nav-menu .el-menu-item {
  height: 50px;
  line-height: 50px;
}

.nav-menu .el-menu-item .el-icon {
  margin-right: 8px;
  font-size: 18px;
}

.app-header {
  background-color: #fff;
  color: #333;
  border-bottom: 1px solid #e6e6e6;
  padding: 0 20px;
  height: 60px;
  line-height: 60px;
  position: fixed;
  top: 0;
  right: 0;
  left: 200px;
  z-index: 999;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-content h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
}

.app-main {
  margin-left: 200px;
  margin-top: 60px;
  padding: 20px;
  background-color: #f5f7fa;
  min-height: calc(100vh - 60px);
}

/* 响应式布局 */
@media screen and (max-width: 768px) {
  .app-aside {
    width: 64px !important;
  }
  
  .app-title {
    display: none;
  }
  
  .app-header {
    left: 64px;
  }
  
  .app-main {
    margin-left: 64px;
  }
}
</style> 